<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDocumentOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('qh_document_orders', function (Blueprint $table) {
            $table->id();
            $table->integer('userId', false, true)->comment('用户ID');
            $table->integer('documentId', false, true)->comment('文档ID');
            $table->string('tradeNo')->comment('订单号');
            $table->string('wxTradeNo')->nullable()->comment('微信订单号');
            $table->string('wxSign')->nullable()->comment('微信wxSign');
            $table->string('wxPrepayId')->nullable()->comment('微信wxPrepayId');
            $table->string('wxNonceStr')->nullable()->comment('微信wxNonceStr');
            $table->string('refundTradeNo')->nullable()->comment('退款单号');
            $table->decimal('price')->comment('金额');
            $table->tinyInteger('status')->default(1)->comment('状态，1：未支付，2：已支付，3：手动支付，4：已完成，5：待发货，6：已发货，9：已退款');
            $table->dateTime('buyAt')->comment('购买时间');
            $table->text('address')->nullable()->comment('收获地址');
            $table->string('express')->nullable()->comment('快递信息');
            $table->dateTime('payAt')->nullable()->comment('支付时间');
            $table->dateTime('sendAt')->nullable()->comment('发货时间');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE qh_document_orders comment '文档购买订单'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('qh_document_orders');
    }
}
